package com.cskaoyan.util;

import lombok.Getter;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import java.io.IOException;

/**
 * SqlSessionFactory单例工具类
 *
 * @author 侯嘉
 * @since 2024/04/10 10:47
 */

public class SqlSessionFactoryUtil {
    private static final String MYBATIS_LOCATION = "config/mybatis-config.xml";
    @Getter
    private static SqlSessionFactory sqlSessionFactory;

    static {
        try {
            sqlSessionFactory = new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream(MYBATIS_LOCATION));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
